<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,role-scalable=no" />
		<title>添加操作</title>
		<link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="/admin/css/admin.css" />
	</head>
	<body>
		<div class="wrap-container">
			<form class="layui-form" style="width: 90%;padding-top: 20px;">
					<div class="layui-form-item">
						<label class="layui-form-label">操作编号：</label>
						<div class="layui-input-block">
							<input type="text" name="operationCode" required lay-verify="required" placeholder="请输入操作编号" autocomplete="off" class="layui-input">
						</div>

					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">操作描述：</label>
						<div class="layui-input-block">
							<input type="text" name="operationDesc" required lay-verify="required" placeholder="请输入操作描述" autocomplete="off" class="layui-input">
						</div>

					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">站点：</label>
						<div class="layui-input-block">
							<input type="text" name="site" required lay-verify="required" placeholder="站点..." autocomplete="off" class="layui-input">
						</div>
					</div>

				<div class="layui-form-item">
					<label class="layui-form-label">创建人：</label>
					<div class="layui-input-block">
						<input type="text" name="createBy" required lay-verify="required" placeholder="创建人..." autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">操作类型：</label>
					<div class="layui-input-block">
						<input type="radio" name="operationType" value="0" title="按键" checked>
						<input type="radio" name="operationType" value="1" title="旋钮">
						<input type="radio" name="operationType" value="2" title="语音">
					</div>
				</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="addOperation">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script src="/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//Demo
			layui.use(['form'], function() {
				var form = layui.form;
				form.render();
				$ = layui.jquery;
				//监听提交
				form.on('submit(addOperation)', function(data) {
					layer.msg(JSON.stringify(data.field));
					$.ajax({
						type: "post",
						data: data.field,
						url: "http://localhost:8080/operation/addOperation",
						error: function (XMLHttpRequest, textStatus, errorThrown) {
							alert("系统异常，请联系管理员!");
						},
						success: function (data) {
								layer.alert(data.message, {
									skin: 'layui-layer-molv' //样式类名  自定义样式
									, closeBtn: 1    // 是否显示关闭按钮
									, anim: 1 //动画类型
									, icon: 6    // icon
								});
						}
				});
					return false;
				});
			});
		</script>
	</body>

</html>